package PTA;

import java.io.*;
import java.util.Scanner;

public class Lx01 {
    public static void main(String[] args) throws  IOException {
        Scanner scan = new Scanner(System.in);
        String fileName = null;
        String fileConten = null;
        System.out.println("请输入文件名称");
        if(scan.hasNextLine()) {
            fileName = scan.nextLine();
            System.out.println("请输入文件内容");
            if(!scan.hasNextLine()) {
                fileConten = scan.nextLine();
                File file = new File(fileName);
                if(!file.getParentFile().exists()) {
                    file.getParentFile().mkdirs();
                }
                OutputStream outputStream = new FileOutputStream(file);
                outputStream.write(fileConten.getBytes());
                outputStream.close();
            }
        }
        System.out.println("保存完毕");
    }
}